import React, { PropTypes } from 'react'
import _ from 'lodash'

import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { navActions } from './reducer'

@connect(
  state => ({navigation: state.navigation, params: state.params}),
  dispatch => ({actions: bindActionCreators({...navActions}, dispatch)})
)
class Navigation extends React.Component {
  constructor(props) {
    super(props)
    this.onModifyPasswordHandle = this.onModifyPassword.bind(this)
  }

  componentDidMount() {
  }

  render () {
    let { navigation } = this.props
    return (
      <div>
        {
          _.map(navigation.menus, (v, k) => {
            return (
              <div key={k}>
                {v}
              </div>
            )
          })
        }
        <button className='btn btn-default' onClick={this.onModifyPasswordHandle}>修改密码</button>
      </div>
    )
  }

  onModifyPassword(e) {
    e.preventDefault();
    this.props.actions.modifyPassword()
  }
}

export default Navigation
